home *** CD-ROM | disk | FTP | other *** search
- REBOL [
- Title: "Build Currency conversion table"
- Author: "Dick Whiting"
- Email: dwhiting@europa.com
- Date: 09-Oct-1998
- File: %bldrates.r
- Purpose: {
- Build a currency conversion series and saves to disk
- }
- Comment: {
-
- Reads the currency table at pacific.commerce and parses
- it into a REBOL series. The series is then saved as a
- file and can be used with convert.r for doing currency
- conversions and with currency.r for locating currencies
- by partial string lookups, e.g. "finn" finds FIM Finnish...
-
- The output filename is hardcoded as %rates.table
-
- If run with a first argument of "PIPE" then writes a message
- to the second argument which should be PIPE:some.pipe.name
-
- }
- ]
-
-
- if pick rebol/args 1 [
- mode: pick rebol/args 1
- pipe: make file! pick rebol/args 2
- ]
- else [
- mode: "NONE"
- pipe: "NONE"
- ]
-
- t1: make time! fourth now
-
- rpage: read http://pacific.commerce.ubc.ca/xr/rates.html
-
- rpage: find rpage "<td align"
-
- rtabl: ["USD" "U.S. Dollar" "1"]
-
- while [found? find rpage "<tt>"] [
-
- code: copy/part skip (find rpage "<tt>") 4 find rpage "</tt>"
-
- rpage: find rpage "left>"
- name: copy/part skip rpage 5 find rpage "</td>"
-
- loop 3 [rpage: skip (find rpage "right>") 6]
-
- exch: copy/part rpage find rpage "</td>"
-
- if code <> "USD" [
- insert tail rtabl reduce [code name exch]
- ]
- ]
-
- rtabl: head rtabl
-
- save %rates.table rtabl
-
- t2: make time! fourth now
-
- entries: length? rtabl
-
- if entries > 3 [
- if mode = "PIPE" [
- write pipe "Done building rates table"
- write newline
- quit
- ]
- else [
- print "Done building rates table"
- print ["Elapsed time: " t2 - t1]
- halt
- ]
- ]
- else [
- if mode = "PIPE" [
- write pipe "Bldrates.r unsuccessful"
- write newline
- quit
- ]
- else [
- print "Bldrates.r unsuccessful"
- halt
- ]
- ]
-
-